
.extern switch_to_hrc
.global __JUMP_TO_MASKROM
.section .volatile_ram_code
 __JUMP_TO_MASKROM:
    ssp = 0x10c20
    sp = ssp
    usp = 0x11020

 	call hw_mmu_disable
	call spi_for_maskrom_init
    call switch_to_hrc

    r1_r0 = 0
    r3_r2 = 0
    r5_r4 = 0
    r7_r6 = 0
    r9_r8 = 0
    r11_r10 = 0
    r13_r12 = 0
    r15_r14 = 0

    psr = r0
    rete = r0
    retx = r0
    rets = r0
    reti = r0
    reti = 0x110000
	rti




.global __DEV_UPDATA_JUMP
.section .volatile_ram_code
__DEV_UPDATA_JUMP:
    ssp = 0x10c20
    sp = ssp
    usp = 0x11020

    r1 = r0		    //SOFT_FLAG_BOOT_SPI_A = BIT(2)   SPI_B = BIT(3)
    r0 = 0x2bede
    b[r0] = r1

 	call hw_mmu_disable
	call spi_for_maskrom_init

    r0 = 0
    r1 = 0x10820	//stack_bss_begin
    r2 = 0x800 //stack_bss_size
    r2 >>= 2
1:
    rep r2 {
    [r1++] = r0
    }
    if(r2 != 0) goto 1b

    r0 = 0
    r1 = 0x11340	//var_bss_begin
    r2 = 0xe4	//var_bss_size
    r2 >>= 2
1:
    rep r2 {
    [r1++] = r0
    }
    if(r2 != 0) goto 1b

    //给maskrom boot_info.sys_clk赋值
    r1 = 24000000
    r0 = 0x2bee0
    [r0] = r1


    r1_r0 = 0
    r3_r2 = 0
    r5_r4 = 0
    r7_r6 = 0
    r9_r8 = 0
    r11_r10 = 0
    r13_r12 = 0
    r15_r14 = 0

    psr = r0
    rete = r0
    retx = r0
    rets = r0
    reti = r0
    reti = 0x1120c6
	rti

.extern hw_mmu_disable
.extern spi_for_maskrom_init
.global __BT_UPDATA_JUMP
.section .volatile_ram_code
 __BT_UPDATA_JUMP:
    ssp = 0x10c20
    sp = ssp
    usp = 0x11020

 	call hw_mmu_disable
	call spi_for_maskrom_init

    r0 = 0
    r1 = 0x10820	//stack_bss_begin
    r2 = 0x800 //stack_bss_size
    r2 >>= 2
1:
    rep r2 {
    [r1++] = r0
    }
    if(r2 != 0) goto 1b

    r0 = 0
    r1 = 0x11340	//var_bss_begin
    r2 = 0xe4	//var_bss_size
    r2 >>= 2
1:
    rep r2 {
    [r1++] = r0
    }
    if(r2 != 0) goto 1b

    //给maskrom boot_info.sys_clk赋值
    r1 = 24000000
    r0 = 0x2bee0
    [r0] = r1

    r1 = 0b1100		//SOFT_FLAG_BOOT_SPI_ALL= BIT(2)|BIT(3)
    r0 = 0x2bede	//g_spi_port= SOFT_FLAG_BOOT_SPI_ALL
    b[r0] = r1

    r1_r0 = 0
    r3_r2 = 0
    r5_r4 = 0
    r7_r6 = 0
    r9_r8 = 0
    r11_r10 = 0
    r13_r12 = 0
    r15_r14 = 0
    psr = r0
    rete = r0
    retx = r0
    rets = r0
    reti = r0
    reti = 0x111f94
	//reti = 0x1120c6
	rti

.global usb_upgrade_mode
.type usb_upgrade_mode, @function
.section .volatile_ram_code
usb_upgrade_mode:

    call debug_disable
    call hw_mmu_disable

    r0 = 0
	r1 = 0x28000
	r2 = 0x5aa0
    r2 >>= 2
.L_ram_clr:
	rep r2 {
	[r1++] = r0
	}
    if(r2 > 0) goto .L_ram_clr

    ssp = 0x28c20
    usp = 0x29020
    sp = usp

    reti = 0x1036a0
    rti

.size usb_upgrade_mode, . - usb_upgrade_mode
